/*
 * Copyright (c) 2010 Curtis Boyden.  All rights reserved. 
 * This software was developed by Curtis Boyden and is provided under the terms 
 * of the GNU Lesser General Public License, Version 2.1. You may not use 
 * this file except in compliance with the license. If you need a copy of the license, 
 * please go to http://www.gnu.org/licenses/lgpl-2.1.txt. The Original Code is ejMud
 * (Ewerp Java MUD).  The Initial Developer is Curtis Boyden.
 *
 * Software distributed under the GNU Lesser Public License is distributed on an "AS IS" 
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
 * the license for the specific language governing your rights and limitations.
*/

package com.ewerp.mud.characters;

import java.util.ArrayList;
import java.util.List;

import com.ewerp.mud.core.session.ISession;
import com.ewerp.mud.entitycore.descriptions.BaseDescription;
import com.ewerp.mud.entitycore.descriptions.IDescription;
import com.ewerp.mud.entitycore.descriptions.meta.IDescriptionMeta;
import com.ewerp.mud.entitycore.descriptions.meta.VisibleDescription;
import com.ewerp.mud.messages.IMessage;
import com.ewerp.mud.security.permissions.IPermission;

public class Player extends BaseCharacter implements ISessionBoundCharacter {
    
    protected ISession session;
    protected String name;
    protected List<IPermission> permissions = new ArrayList<IPermission>();
    
    public void handleMessage(IMessage message) {
        session.processMessage(message);
    }

    @Override
    public ISession getSession() {
        return session;
    }

    @Override
    public void setSession(ISession session) {
        this.session = session;
    }

    @Override
    public IDescription getDescription(Class<? extends IDescriptionMeta> type) {
        if(type.equals(VisibleDescription.class)) {
            return new BaseDescription(new VisibleDescription(), name);
        }
        
        return null;
    }

    /**
     * This is not used for characters, the description is generated
     */
    @Override
    public void setDescription(IDescription description) {
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public List<IPermission> getPermissions() {
        return permissions;
    }
}
